package principle.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author malguy-wang sir
 * @create ---
 */
public class college extends organizationComponent {
    //构造器
    public college(String name, String des) { super(name, des); }
    List<organizationComponent> list = new ArrayList<>();//存放department
    @Override//实际开发中的college和university的add、remove方法不一定相同
    protected void add(organizationComponent organizationComponent) { list.add(organizationComponent); }
    @Override
    protected void remove(organizationComponent organizationComponent) {list.remove(organizationComponent); }
    @Override
    public String getName() { return super.getName(); }
    @Override
    public String getDes() { return super.getDes(); }
    //输出university包含的所有college
    @Override
    protected void print() {
        System.out.println(getName());
        //遍历
        for (organizationComponent organizationComponent : list) {
            organizationComponent.print();
        }
    }
}
